package com.prathiba.tictactoe;

public class Coordinate implements Comparable<Object> {
	private int x, y;

	public Coordinate(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public boolean equals(Object c) {
		Coordinate other = (Coordinate) c;

		if (this.x == other.x && this.y == other.y)
			return true;

		else
			return false;

	}

	@Override
	public String toString() {
		return "Coordinate:x=" + this.x + ";" + "y=" + this.y;

	}

	public int getX() {

		return x;
	}

	public int getY() {
		return y;
	}

	public int toInt() {
		int val = (3 * this.x) + this.y;
		return val;
	}

	public static Coordinate value(int val) {
		int a = val / 3;
		int b = val % 3;
		Coordinate c = new Coordinate(a, b);
		return c;
	}

	public Coordinate horizontalNext() {
		// this.y = this.y + 1;
		return new Coordinate(this.x, this.y + 1);
	}

	public Coordinate verticalNext() {
		// this.x = this.x + 1;
		return new Coordinate(this.x + 1, this.y);
	}

	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		return 0;
	}
}